package com.example.springboot01.event;

import org.springframework.context.ApplicationEvent;

import java.util.Date;

/**
 * 通过extends ApplicationEvent，将此类注册为一个事件类
 *
 * @author keyer
 * @Description : 事件源
 * Created by cyd on 2021-04-30 23:26:46
 */
public class DemoEvent extends ApplicationEvent {
    private static final long serialVersionUID = 1L;
    private final String msg;
    private final Date date;

    /**
     * 事件源的构造器，监听器就监听它
     *
     * @param source 将来会将context传入
     */
    public DemoEvent(Object source, String msg, Date date) {
        super(source);
        this.msg = msg;
        this.date = date;
    }

    public String getMsg() {
        return msg;
    }

    public Date getDate() {
        return date;
    }
}
